﻿<%@ Page Language="C#"  %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="TarreOA.TarreOABLL" %>
<%@ Import Namespace="TarreOA.TarreOAModels  " %>

<script runat="server">
    
    private int cgLmid;
    
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        if (ViewState["cgLmid"] != null)
        {
            cgLmid = (int)ViewState["cgLmid"]; 
        }  
        User curLoginUser = (User)Session["user"];
        string cgLinkManName = Request[this.TxtName.ClientID];
        int comGroupId = int.Parse(Request.Params.GetValues(this.DdlGroup.ClientID)[0]);
        int cgLinkManSec = int.Parse(Request.Params.GetValues(this.DropDownList2.ClientID)[0]);
        DateTime cgLinkManBirthday = new DateTime();
        if (!"".Equals(this.TxtBirthday.Text.Trim()))
        {
            try
            {
                cgLinkManBirthday = DateTime.Parse(Request[this.TxtBirthday.ClientID]);
            }
            catch
            {
                ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "alert('日期输入有错！');", true);
            }
        }
        string cgLinkManName2 = Request[this.TxtName2.ClientID];
        string cgLinkManDuty = Request[this.TxtDuty.ClientID];
        string cgLinkManUnitName = Request[this.TxtUnitName.ClientID];
        string cgLinkManUnitAddress = Request[this.TxtUnitAddress.ClientID];
        string cgLinkManUnitTelephone = Request[this.TxtUnitTelephone.ClientID];
        string cgLinkManUnitFacsimile = Request[this.TxtUnitFacsimile.ClientID];
        string cgLinkManHomeAddress = Request[this.TxtFamilyAddress.ClientID];
        string cgLinkManHomeTelephone = Request[this.TxtFamilyTelephone.ClientID];
        string cgLinkManHandset = Request[this.TxtHandset.ClientID];
        string cgLinkManEmail = Request[this.TxtEmail.ClientID];
        string cgLinkManQicq = Request[this.TxtOicq.ClientID];
        string cgLinkManMsn = Request[this.TxtMSN.ClientID];
        string cgLinkManRemark = Request[this.TxtRemark.ClientID];
        UserCommunicationGroupLinkMantbService ucgLinkMantbService = new UserCommunicationGroupLinkMantbService();
        ucgLinkMantbService.updateComGroupLinkManInfoByGroupLinkManId(cgLmid, comGroupId, cgLinkManName, cgLinkManSec, cgLinkManBirthday,
            cgLinkManName2, cgLinkManDuty, cgLinkManUnitName, cgLinkManUnitAddress, cgLinkManUnitTelephone, cgLinkManUnitFacsimile,
            cgLinkManHomeAddress, cgLinkManHomeTelephone, cgLinkManHandset, cgLinkManEmail, cgLinkManQicq, cgLinkManMsn, cgLinkManRemark);
        Response.Redirect("CommunicationGroupLinkManShow.aspx?cgid=" + comGroupId);     
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.DdlGroup.Items.Clear();
            if (Request["cgLmid"] != null)
            {
                User curLoginUser = (User)Session["user"];
                cgLmid = int.Parse(Request["cgLmid"]);
                UserCommunicationGrouptbService ucgtbService = new UserCommunicationGrouptbService();
                UserCommunicationGroupLinkMantbService ucgLinkMantbService = new UserCommunicationGroupLinkMantbService();
                UserCommunicationGroupLinkMantb ucgLinkMan = ucgLinkMantbService.findByGroupLinkManId(cgLmid);
                List<UserCommunicationGrouptb> list = ucgtbService.findByUserLoginName(curLoginUser.LoginName);
                if (list != null && list.Count > 0)
                {
                    foreach (UserCommunicationGrouptb ucgtb in list)
                    {
                        this.DdlGroup.Items.Add(new ListItem(ucgtb.ComGroupName, ucgtb.ComGroupId.ToString()));
                    }
                }
                if (ucgLinkMan != null)
                {
                    for (int i = 0; i < this.DdlGroup.Items.Count; i++)
                    {
                        if (ucgLinkMan.ComGroup.ComGroupId.ToString().Equals(this.DdlGroup.Items[i].Value))
                        {
                            this.DdlGroup.Items[i].Selected = true;
                        }
                    }
                    this.TxtName.Text = ucgLinkMan.GroupLinkManName;
                    this.Title = ucgLinkMan.GroupLinkManName + "的详细信息";
                    for (int i = 0; i < this.DropDownList2.Items.Count; i++)
                    {
                        if (ucgLinkMan.GroupLinkManSec.ToString().Equals(this.DropDownList2.Items[i].Value))
                        {
                            this.DropDownList2.Items[i].Selected = true;
                        }
                    }
                    this.TxtBirthday.Text = ucgLinkMan.GroupLinkManBirthday.ToShortDateString();
                    this.TxtName2.Text = ucgLinkMan.GroupLinkManName2;
                    this.TxtDuty.Text = ucgLinkMan.GroupLinkManDuty;
                    this.TxtUnitName.Text = ucgLinkMan.GroupLinkManUnitName;
                    this.TxtUnitAddress.Text = ucgLinkMan.GroupLinkManUnitAddress;
                    this.TxtUnitTelephone.Text = ucgLinkMan.GroupLinkManUnitTelephone;
                    this.TxtUnitFacsimile.Text = ucgLinkMan.GroupLinkManUnitFacsimile;
                    this.TxtFamilyAddress.Text = ucgLinkMan.GroupLinkManHomeAddress;
                    this.TxtFamilyTelephone.Text = ucgLinkMan.GroupLinkManHomeTelephone;
                    this.TxtHandset.Text = ucgLinkMan.GroupLinkManHandset;
                    this.TxtEmail.Text = ucgLinkMan.GroupLinkManEmail;
                    this.TxtOicq.Text = ucgLinkMan.GroupLinkManOicq;
                    this.TxtMSN.Text = ucgLinkMan.GroupLinkManMsn;
                    this.TxtRemark.Text = ucgLinkMan.GroupLinkManRemark;
                    this.TxtBirthday.Attributes.Add("onfocus", "calendar()"); 
                }
                ViewState["cgLmid"] = cgLmid;
            }
        } 
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link href="../CSS/TableStyle.css" rel="Stylesheet" />
           <link rel="Stylesheet" type="text/css" href="../../Styles/right_style.css" />
    <script type="text/javascript" src="../../Scripts/jquery.ui/js/jquery.js"></script>
    <script type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>

    <style type="text/css">
<!--
html{ scrollbar-base-color: #dbecf8; scrollbar-arrow-color: #2a8ed1; scrollbar-track-color: #bdddf2; scrollbar-3dlight-color: #2886c5; scrollbar-darkshadow-color: #2886c5;
scrollbar-face-color: #dbecf8; scrollbar-shadow-color: #dbecf8;  }
-->
</style>

</head>
<body>
    <form id="form1" runat="server">
        <div class="sub_right_top">
    <div class="add_book_guanli1" align="left">编辑联系人</div>
            <table width="97%" border="1" cellpadding="0" cellspacing="0" bordercolor="#72b0d8" style="border-collapse:collapse; ">
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>分组</strong></td>

          </tr>
          
          <tr>
            <td width="170">分组：</td>
            <td width="597">
              <asp:DropDownList ID="DdlGroup" runat="server" Width="140">
                    </asp:DropDownList>
            </td>
          </tr>
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>个人信息</strong></td>
          </tr>
          <tr>
            <td width="170">姓名：</td>

            <td>
             <asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">性别：</td>
            <td>
              <asp:DropDownList ID="DropDownList2" runat="server" Width="140px">
                        <asp:ListItem Value="0">男</asp:ListItem>
                        <asp:ListItem Value="1">女</asp:ListItem>
                    </asp:DropDownList>
            </td>
          </tr>
          <tr>
            <td width="170">生日：</td>

            <td>
              <asp:TextBox ID="TxtBirthday" runat="server" CssClass="Wdate" onClick="WdatePicker()"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">昵称：</td>
            <td>
              <asp:TextBox ID="TxtName2" runat="server"></asp:TextBox>

            </td>
          </tr>
          <tr>
            <td width="170">职务：</td>
            <td>
              <asp:TextBox ID="TxtDuty" runat="server"></asp:TextBox>
            </td>
          </tr>

          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>联系方式(单位)</strong></td>
          </tr>
          <tr>
            <td width="170">单位名称：</td>
            <td>
             <asp:TextBox ID="TxtUnitName" runat="server"></asp:TextBox>
            </td>

          </tr>
          <tr>
            <td width="170">单位地址：</td>
            <td>
              <asp:TextBox ID="TxtUnitAddress" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>

            <td width="170">单位电话：</td>
            <td>
              <asp:TextBox ID="TxtUnitTelephone" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">单位传真：</td>
            <td>
            <asp:TextBox ID="TxtUnitFacsimile" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>联系方式(家庭)</strong></td>
          </tr>
          <tr>
            <td width="170">家庭住址：</td>

            <td>
              <asp:TextBox ID="TxtFamilyAddress" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">家庭电话：</td>
            <td>
              <asp:TextBox ID="TxtFamilyTelephone" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">手机：</td>
            <td>
              <asp:TextBox ID="TxtHandset" runat="server"></asp:TextBox>
            </td>
          </tr>

          <tr>
            <td width="170">电子邮件：</td>
            <td>
              <asp:TextBox ID="TxtEmail" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">QQ号码：</td>

            <td>
              <asp:TextBox ID="TxtOicq" runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td width="170">MSN号码：</td>
            <td>
              <asp:TextBox ID="TxtMSN" runat="server"></asp:TextBox>

            </td>
          </tr>
          <tr bgcolor="#b1d5ef">
            <td colspan="2"><strong>备注</strong></td>
          </tr>
          <tr>
            <td colspan="2">
              <asp:TextBox ID="TxtRemark" runat="server" Width="100%" Height="97px" TextMode="MultiLine"
                       ></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td colspan="2"><div class="disk_queding_top">
            <asp:Button ID="BtnUpdate" runat="server" Text="" Width="72px" OnClick="BtnUpdate_Click" CssClass="queding_anniu"/>
            </div>
          <div class="disk_back_top">
            <input id="Button1" onclick="window.history.go(-1)" style="width: 72px; height: 24px"
                        type="button" value=""  class="fanhui_anniu"/></div>
             <div class="clear"></div>            
      </td>
          </tr>
        </table>
    </div>
    </form>
</body>
</html>
